package com.zhuss.core.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.config.type.CreateConfigTypeBo;
import com.zhuss.bean.bo.core.config.type.DecrConfigTypeSortBo;
import com.zhuss.bean.bo.core.config.type.DeleteConfigTypeBo;
import com.zhuss.bean.bo.core.config.type.IncrConfigTypeSortBo;
import com.zhuss.bean.bo.core.config.type.UpdateConfigTypeBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.AabException;

/**
 * 配置类型操作service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-20 11:58
 *
 */
@Component("configTypeOperateService")
public class ConfigTypeOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("configTypeCreate")
	private Processor<Object, CreateConfigTypeBo> configTypeCreate;
	
	@Autowired
	@Qualifier("configTypeUpdate")
	private Processor<Object, UpdateConfigTypeBo> configTypeUpdate;
	
	@Autowired
	@Qualifier("configTypeDelete")
	private Processor<Object, DeleteConfigTypeBo> configTypeDelete;
	
	@Autowired
	@Qualifier("configTypeIncrSort")
	private Processor<Object, IncrConfigTypeSortBo> configTypeIncrSort;
	
	@Autowired
	@Qualifier("configTypeDecrSort")
	private Processor<Object, DecrConfigTypeSortBo> configTypeDecrSort;
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws AabException {
		
		CreateConfigTypeBo bo = (CreateConfigTypeBo) param;
		
		configTypeCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws AabException {
    	
		UpdateConfigTypeBo bo = (UpdateConfigTypeBo) param;
		
		configTypeUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws AabException {
		
		DeleteConfigTypeBo bo = (DeleteConfigTypeBo) param;
		
		configTypeDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 上移
	 * 顺序
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void incrSort(Object param) throws AabException {
		
		IncrConfigTypeSortBo bo = (IncrConfigTypeSortBo) param;
		
		configTypeIncrSort.process(bo);
		
		return null;
	}
	
	/**
	 * 下移
	 * 顺序
	 */
	@Transactional(rollbackFor = Exception.class)
	public Void decrSort(Object param) throws AabException {
		
		DecrConfigTypeSortBo bo = (DecrConfigTypeSortBo) param;
		
		configTypeDecrSort.process(bo);
		
		return null;
	}
	
}

